from itertools import product


class SaveToTxtPipeline():
    file_name = "product.txt"
    file = None

    def open_spider(self,spider):
        self.file= open(self.file_name,"a",encoding="utf-8")

    def process_item(self,item,spider):
        product_str = item+'\n'
        self.file.write(product_str)
        return item

    def close_spider(self,spider):
        self.file.close()
